<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>章节审核</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css" media="all" />
</head>
<body class="childrenBody">

<table id="SignInforData" lay-filter="newsList"></table>

<!--操作-->
<script type="text/html" id="newsListBar">
    <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="ok">同意</a>
    <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="no">拒绝</a>
    <%-- <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
     <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="look">预览</a>--%>
</script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/dateFormat.js"></script>
<script>

    layui.use(['laydate','layer','jquery','table'], function(){
        var layer = layui.layer;
        var $ = layui.jquery;
        var table = layui.table;

        table.render({
            elem: '#SignInforData',
            url : '${pageContext.request.contextPath}/admin/getShChapterList',
            cellMinWidth : 95,
            toolbar:"default",
            page : true,
            limit : 15,
            limits : [15,20,30,40,50],
            id : "newsList",
            cols : [[
                /* {type: "checkbox", fixed:"left", width:50},*/
                {field: 'authorName', title: '作者', align:'center'},
                {field: 'novelName', title: '小说名称',  align:'center'},
                {field: 'quarterNoZh', title: '卷',  align:'center'},
                {field: 'chapterNoZh', title: '章',  align:'center'},
                {field: 'chapterName', title: '章节名称',  align:'center'},
                {field: 'content', title: '内容',  align:'center'},
                {field: 'createTime', title: '创建时间',  align:'center',templet:function (data) {

                        return dateFormat('yyyy-MM-dd',new Date(data.createTime))
                    }},
                {title: '操作', fixed:"right",width:200, templet:'#newsListBar',align:"center"}
            ]]
        });

        table.on('tool(newsList)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                ,layEvent = obj.event; //获得 lay-event 对应的值
            if(layEvent === 'ok'){
                layer.confirm('同意<font color="red">'+data.chapterName+'</font>章节申请', function(d){
                    $.ajax({
                        type:"get",
                        url: "${pageContext.request.contextPath}/admin/agreeChapter/"+data.id+"/"+data.novelId,
                        success:function (data) {
                            if(data.success){
                                layer.alert(data.message,{icon: 1}),function (index) {
                                    layer.close(index);
                                }
                                obj.del(); //删除对应行（tr）的DOM结构
                            }else {
                                layer.msg(data.message,{icon: 5})
                            }
                        },
                    });
                });
            }else if(layEvent === 'no'){
                layer.confirm('拒绝<font color="red">'+data.chapterName+'</font>章节申请', function(d){
                    $.ajax({
                        type:"POST",
                        url: "${pageContext.request.contextPath}/admin/refuseChapter/"+data.id,
                        success:function (data) {
                            if(data.success){
                                layer.alert(data.message,{icon: 1}),function (index) {

                                    layer.close(index);
                                }
                                obj.del(); //删除对应行（tr）的DOM结构
                            }else {
                                layer.msg(data.message,{icon: 5})
                            }
                        },
                    });
                });
            }
        });
    });

</script>
</body>
</html>

